Start Transaction
AutomatR.MSSQLDataBase.Database.StartTransaction
The "Start Transaction" activity in AutomatR for SQL Server databases initiates a transaction, allowing a sequence of database operations to be treated as a single, atomic unit. This activity is essential for maintaining data consistency and integrity in scenarios where multiple operations must be executed together, ensuring that either all operations are committed or none at all.
Properties
Name | Description |
---|---|
Input | |
Connection | Specifies a SQL connection variable used to establish a connection to the database. This connection is essential for executing database operations within the transaction. A variable of type SqlConnection . |
Misc | |
DisplayName | Provides a customizable name for the activity displayed in the workflow. The display name enhances clarity and organization within the automation project. String variables containing the desired display name. |
Optional | |
Delay | Specifies the amount of time (in seconds) to wait before executing the "Start Transaction" activity. This can be useful for handling synchronization issues. Integer variables containing the delay duration. Ex.: If the amount of time is 1000 milliseconds or 1 sec, i.e., 1. |
How to use:
- Drag and drop the "Start Transaction" activity onto the workflow.
- Configure the properties by providing a SQL connection variable to establish a connection to the database.
- Optionally, configure the delay for synchronization purposes.
- Create a sequence of database operations within the "Start Transaction" activity to be treated as a single transaction.
- Execute the workflow to initiate the transaction.
Example: Consider an example where the "Start Transaction" activity is used to initiate a transaction for updating records in a SQL Server database:
Start Transaction:
Connection: sqlConnectionVariable
Delay: 0
Sequence (Database Operations):
Update Table1
Insert into Table2
...
(Transaction automatically commits if no errors occur during the sequence)
In this example, the activity initiates a transaction using the specified SQL connection variable and executes a sequence of database operations. The transaction automatically commits if no errors occur during the sequence. If any error occurs, the transaction is rolled back, ensuring data consistency.